package com.example.demo.util;

import net.dongliu.apk.parser.ApkFile;
import net.dongliu.apk.parser.bean.ApkMeta;
import net.dongliu.apk.parser.bean.Icon;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;

/**
 * @ClassName APKPase
 * @Description APKPase
 * @Author Administrator
 * @Date 2020/5/18 0:09
 * @Version 1.0
 */
public class APKPase {

    public static void main(String[] args) {
            try {
                //apk的绝对地址
                ApkFile apkFile = new ApkFile(new File("D:\\1.apk"));
                ApkMeta apkMeta = apkFile.getApkMeta();
                Icon iconFile = apkFile.getIconFile();
                byte[] data = iconFile.getData();
                BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("./file/test.png"), 1024);
                bos.write(data);
                bos.flush();
                bos.close();
//                System.out.println(data);

                System.out.println(apkMeta.getLabel());
                System.out.println(apkMeta.getPackageName());
                System.out.println(apkMeta.getVersionCode());
                System.out.println(apkMeta.getVersionName());
                System.out.println(apkMeta.getInstallLocation());
                System.out.println(apkMeta.getUsesFeatures());
                System.out.println(apkMeta.getGlEsVersion());


                System.out.println("----------------");
                System.out.println(apkMeta.getPermissions());
                System.out.println("----------------");
                System.out.println(apkMeta.getUsesPermissions());


                System.out.println(apkMeta.toString());
            } catch (Exception e) {
                e.printStackTrace();
            }
    }
}
